/**
 * Created by 白雨浓 on 2019/1/16 16:07.
 */
import convert2Ast from "./convert2Ast";

const toRule = (ast) => {
  let temp = 'return {\n';

  ast.items.forEach(item => {
    temp += `    ${item.field}: [
        {required: true, message: '请输入${item.annotation}', trigger: 'blur'},
    ],\n`;
  });

  temp += '}';

  return temp;
};

export default (entity) => {
  return toRule(convert2Ast(entity));
}
